<div class="row">
    <div class="col-lg-12">
        <section class="panel">
            <header class="panel-heading">View Hostory </header>
            <div class="table-responsive">
                <table class="table table-striped b-t text-small">
                    <thead>
                        <tr>
                            <th width="20">
                                STT</th>
                            <th class="th-sortable" data-toggle="class">Email Title <span class="th-sort"><i class="fa fa-sort-down text"></i><i class="fa fa-sort-up text-active"></i><i class="fa fa-sort"></i></span></th>
                            <th>No. of Emails sent</th>
                            <th>	No. of open</th>
                            <th width="30">View detail</th>
                        </tr>
                    </thead>
                    <tbody>

                    	<?php $count=0; ?>
                        <?php foreach($emails as $email): $count++;?>
						<tr>
							<td><?php echo $count; ?></td>
							<td><?php echo $email['Email']['title']?></td>
							<td><?php echo count($email['Customer'])?></td>
							<td>
								<?php
									$email_opended = 0;
									foreach ($email['Customer'] as $k){

										// if($v['customer'])
										// pr($v['CustomersEmail']['opened']);
										if($k['CustomersEmail']['opened'] == 1){

											$email_opended += 1;
										}
									}
								echo $email_opended;
								?>
							</td>
							<td><?php echo $this->Html->link('View detail', array('controller'=>'emails', 'action'=>'view', 
                            $email['Email']['id']), array('id' => 'viewemail')) ;?></td>
						</tr>
					<?php endforeach ;?>
                    
                    </tbody>
                </table>
            </div>
            <footer class="panel-footer">
                <div class="row">
                   <!--  <div class="col-sm-3 text-center"><small class="text-muted inline m-t-small m-b-small">showing 20-30 of 50 items</small> </div> -->
                    <div class="col-sm-5 text-right text-center-sm">
                        <div class="col-sm-5 text-right text-center-sm">
                                    
                                    <ul class="pagination pagination-small m-t-none m-b-none">
                                        <?php
                                            echo $this->Paginator->prev(__('prev'), array('tag' => 'li'), null, array('tag' => 'li','class' => 'disabled','disabledTag' => 'a'));
                                            echo $this->Paginator->numbers(array('separator' => '','tag' => 'li', 'currentTag' => 'a', 'currentClass' => 'active')); 
                                            echo $this->Paginator->next(__('next'), array('tag' => 'li','currentClass' => 'disabled'), null, array('tag' => 'li','class' => 'disabled','disabledTag' => 'a'));
                                        ?>
                                    </ul>
                                </div>
                    </div>
                </div>
            </footer>
        </section>
    </div>
</div>